﻿<UserControl x:Class="MainGameModule.Views.QuizView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/YourWorld.Common;component/Styles/CommonResourcesDictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot"
          Width="560"
          Background="Transparent"
          Height="380">
        
        <VisualStateManager.CustomVisualStateManager>
            <ei:ExtendedVisualStateManager />
        </VisualStateManager.CustomVisualStateManager>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup"
                              ei:ExtendedVisualStateManager.UseFluidLayout="True">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0">
                        <VisualTransition.GeneratedEasingFunction>
                            <CubicEase EasingMode="EaseIn" />
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                    <VisualTransition GeneratedDuration="0:0:1"
                                      To="ShowAnswer">
                        <VisualTransition.GeneratedEasingFunction>
                            <CubicEase EasingMode="EaseIn" />
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="ShowAnswer">
                    <Storyboard>
                        <DoubleAnimation Duration="0"
                                         To="-1"
                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)"
                                         Storyboard.TargetName="AnswersPanel"
                                          />
                        <DoubleAnimation Duration="0"
                                         To="-150"
                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)"
                                         Storyboard.TargetName="AnswersPanel"
                                          />
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)"
                                                       Storyboard.TargetName="InfoPanel">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Thickness>236,0,34,0</Thickness>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.HorizontalAlignment)"
                                                       Storyboard.TargetName="InfoPanel">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <HorizontalAlignment>Stretch</HorizontalAlignment>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)"
                                                       Storyboard.TargetName="InfoPanel">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <System:Double>NaN</System:Double>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="InfoPanel">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="HideAnswer" />
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Path x:Name="BackgroundRectangle"
              Grid.RowSpan="6"
              Data="M187.2383,141.7393C187.2383,141.7393,176.3913,144.7943,172.5713,149.0723C164.2383,158.4063,166.5713,209.7393,165.2383,221.7393C163.9053,233.7393,163.9053,364.4073,165.2383,397.0733C166.5713,429.7393,165.2383,441.7393,167.9053,452.4053C170.5713,463.0733,178.5713,462.4053,187.2383,465.7393C195.9053,469.0733,317.9053,475.0733,335.2383,475.0733C352.5713,475.0733,497.2383,476.4073,523.9053,475.0733C550.5723,473.7393,617.2393,476.4053,630.5723,469.7393C643.9053,463.0733,651.2383,452.4053,651.2383,435.7393C651.2383,419.0733,652.5713,301.0723,651.2383,249.0723C649.9053,197.0723,651.8313,159.3863,645.9053,150.4063C641.9333,144.3863,629.2383,143.7393,617.9053,141.7393C606.5723,139.7393,419.9053,137.7393,381.2383,138.4063C342.5713,139.0723,187.2383,141.7393,187.2383,141.7393z"
              Stretch="Fill">
            <Path.Effect>
                <DropShadowEffect Opacity="0.5" />
            </Path.Effect>
            <Path.Fill>
                <RadialGradientBrush RadiusX="0.8">
                    <GradientStop Color="#FFD1E778" />
                    <GradientStop Color="#FF4A6305"
                                  Offset="1" />
                </RadialGradientBrush>
            </Path.Fill>
        </Path>

        <Grid x:Name="QuestionsHolder"
              Width="560"
              Background="Transparent"
              Height="380">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <TextBlock Margin="10"
                       FontFamily="Segoa UI"
                       FontSize="35"
                       Foreground="White"
                       FontWeight="ExtraBold"
                       Text="Quiz"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center" />

            <StackPanel Orientation="Horizontal"
                        Grid.Row="1"
                        HorizontalAlignment="Center"
                        Margin="15 20 15 15">
                <TextBlock Text="Question "
                           FontSize="20" />
                <TextBlock Text="{Binding CurrentQuestionNumber}"
                           FontSize="20" />
                <TextBlock Text=" of "
                           FontSize="20" />
                <TextBlock Text="{Binding Questions.Count}"
                           FontSize="20" />
            </StackPanel>
            <TextBlock Text="{Binding CurrentQuestion.Text}"
                       TextAlignment="Center"
                       FontSize="14"
                       Margin="100 0 100 10"
                       Grid.Row="2"
                       TextWrapping="Wrap" />
            <Grid Grid.Row="3">
                <Grid x:Name="AnswersPanel"
                      HorizontalAlignment="Center"
                      RenderTransformOrigin="0.5,0.5">
                    <i:Interaction.Triggers>
                        <i:EventTrigger SourceObject="{Binding ElementName=ShowAnswerButton}"
                                        EventName="Click">
                            <i:Interaction.Behaviors>
                                <ei:ConditionBehavior>
                                    <ei:ConditionalExpression>
                                        <ei:ComparisonCondition />
                                    </ei:ConditionalExpression>
                                </ei:ConditionBehavior>
                            </i:Interaction.Behaviors>
                            <ei:GoToStateAction StateName="ShowAnswer" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid.RenderTransform>
                        <CompositeTransform />
                    </Grid.RenderTransform>

                    <RadioButton Content="{Binding CurrentQuestion.A}"
                                 Margin="5"
                                 x:Name="Answer1"
                                 Foreground="Black" />
                    <RadioButton Grid.Row="1"
                                 Content="{Binding CurrentQuestion.B}"
                                 Margin="5"
                                 x:Name="Answer2"
                                 Foreground="Black" />
                    <RadioButton Grid.Row="2"
                                 Content="{Binding CurrentQuestion.C}"
                                 Margin="5"
                                 x:Name="Answer3"
                                 Foreground="Black" />
                    <RadioButton Grid.Row="3"
                                 Content="{Binding CurrentQuestion.D}"
                                 Margin="5"
                                 x:Name="Answer4"
                                 Foreground="Black" />

                </Grid>
                <Grid x:Name="InfoPanel"
                      Width="250"
                      HorizontalAlignment="Right"
                      Margin="0,0,-256,0"
                      Visibility="Collapsed">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Text="{Binding CurrentQuestion.Explanation}"
                               Grid.Row="1"
                               Margin="10 0 10 0"
                               TextWrapping="Wrap" />
                </Grid>
            </Grid>

            <TextBlock x:Name="ValidityText"
                       Grid.Row="4"
                       HorizontalAlignment="Center"
                       Margin="5"
                       Height="20" />

            <Grid Grid.Row="5">
                <Button x:Name="NextQuestionButton"
                        Command="{Binding NextQuestionCommand}"
                        Click="NextQuestionButton_Click"
                        Content="Next Question"
                        Width="150"
                        Margin="10"
                        Height="38"
                        Style="{StaticResource GwButtonStyle}" Visibility="Collapsed">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <ei:GoToStateAction StateName="HideAnswer" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
                <Button x:Name="ShowAnswerButton"
                        Click="ShowAnswerButton_Click"
                        Content="Show answer"
                        Width="140"
                        Style="{StaticResource GwButtonStyle}"
                        Margin="10"
                        Height="38" />
                <Button x:Name="FinishButton"
                        Visibility="Collapsed"
                        Click="FinishButton_Click"
                        Content="Finish"
                        Style="{StaticResource GwButtonStyle}"
                        Width="100"
                        Margin="10"
                        Height="38" />
            </Grid>
        </Grid>
        <Grid x:Name="OverviewHolder"
              Visibility="Collapsed"
              Width="520"
              Grid.Row="1"
              Height="330"
              Opacity="0.895">

            <StackPanel Orientation="Horizontal"
                        HorizontalAlignment="Center"
                        Margin="15 90 15 15">
                <TextBlock Text="You answered "
                           FontSize="20" />
                <TextBlock Text="{Binding NumberOfCorrectAnswers}"
                           FontSize="20" />
                <TextBlock Text=" of "
                           FontSize="20" />
                <TextBlock Text="{Binding Questions.Count}"
                           FontSize="20" />
                <TextBlock Text=" questions correctly."
                           FontSize="20" />
            </StackPanel>

            <!--<StackPanel Orientation="Horizontal"
                        HorizontalAlignment="Center"
                        Grid.Row="1"
                        Margin="15 130 15 15">
                <TextBlock Text="You earn "
                           FontSize="20" />
                <TextBlock Text="{Binding EarnedExperience}"
                           FontSize="20" />
                <TextBlock Text=" experience."
                           FontSize="20" />
            </StackPanel>-->
        </Grid>

        <Button x:Name="CloseButton"
                HorizontalAlignment="Right"
                VerticalAlignment="Top"
                Margin="20"
                Style="{StaticResource CloseButtonStyle}"
                Command="{Binding CloseQuizCommand}" />

    </Grid>
</UserControl>
